laravel model to array

59

laravel model to array -

use App\Models\User;

$user = User::with('roles')->first();

return $user->toArray();

laravel object to array -

function objectToArray(&$object)
{
    return @json_decode(json_encode($object), true);
}

Comments

Submit
0 Comments